package com.fc.review.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.StrictMode;

public class BaseActivity extends Activity {
	private ProgressDialog progress;
    
    public void showExitDialog(String title,String msg) {
    
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    this);
    

            // set title
            alertDialogBuilder.setTitle(title);

            // set dialog message
            alertDialogBuilder
            
                    .setMessage(msg)
                    .setCancelable(false)
                    .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                            public void  onClick(DialogInterface dialog,int id) {
                                    finish();
                                    
                                    
                            }
                      })
                    .setNegativeButton("No",new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,int id) {
                                    // if this button is clicked, just close
                                    // the dialog box and do nothing
                                    dialog.cancel();
                            }
                    });

                    // create alert dialog
                    AlertDialog alertDialog = alertDialogBuilder.create();

                    // show it
                    alertDialog.show();
                    
                    
            }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            if (android.os.Build.VERSION.SDK_INT > 9) {
                  StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                  StrictMode.setThreadPolicy(policy);
                }
    }
    
    public void showProgress(String message) {
    	if(progress==null) {
            progress = new ProgressDialog(this);
    	}
    //progress.setTitle("Please Wait!!");
    progress.setMessage(message);
    progress.setCancelable(false);
    progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progress.show();
    	}
    
    
    public void hideProgress() {
            if(progress!=null){
            progress.hide();
            //progress=null;
            }
            

    }
}
